//
//  FourthViewController.m
//  OCUI3
//
//  Created by login on 15-6-30.
//  Copyright (c) 2015年 login. All rights reserved.
//

#import "PersonalCenterViewController.h"
#import "Header.h"
#import "PersonalTableViewCell.h"
@interface PersonalCenterViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    UITableView *personalCenter;
    NSMutableDictionary *_cellListDic;

}
@end

@implementation PersonalCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _cellListDic = [NSMutableDictionary dictionary];
    [_cellListDic setObject:@"订单" forKey:@(0)];
    [_cellListDic setObject:@"详情" forKey:@(1)];
    [_cellListDic setObject:@"详细信息" forKey:@(2)];
    [_cellListDic setObject:@"个人" forKey:@(3)];
    [_cellListDic setObject:@"最新消息" forKey:@(4)];
    [_cellListDic setObject:@"我的订单" forKey:@(5)];
    [_cellListDic setObject:@"我的位置" forKey:@(6)];
    [_cellListDic setObject:@"订单" forKey:@(7)];
    [_cellListDic setObject:@"详情" forKey:@(8)];
    [_cellListDic setObject:@"详细信息" forKey:@(9)];
    [_cellListDic setObject:@"个人" forKey:@(10)];
    [_cellListDic setObject:@"最新消息" forKey:@(11)];
    [_cellListDic setObject:@"我的订单" forKey:@(12)];
    [_cellListDic setObject:@"我的位置" forKey:@(13)];

    
    [self initPersonalCenter];
}
#pragma mark - 初始化TableView
- (void)initPersonalCenter
{
    personalCenter = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStylePlain];
    personalCenter.delegate = self;
    personalCenter.dataSource = self;
    [self.view addSubview:personalCenter];
    
}
#pragma mark - ARSegmentControllerDelegate
-(NSString *)segmentTitle
{
    return @"TableView";
}

-(UIScrollView *)streachScrollView
{
    return personalCenter;
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

{
    return _cellListDic.allKeys.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"cellIdentifier";
    PersonalTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[PersonalTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.rightImage.image = [UIImage imageNamed:@"uiimg4"];
    cell.contentLabel.text = _cellListDic[@(indexPath.row)];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return HEIGHT/4;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc]init];
    headerView.backgroundColor = [UIColor lightGrayColor];
    
    
    
    UIButton *personalImage = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    personalImage.frame = CGRectMake(0, 0, 80, 80);
    personalImage.center = CGPointMake(self.view.center.x, HEIGHT/8);
    personalImage.layer.cornerRadius = 80/2;
    personalImage.layer.masksToBounds = YES;
    [personalImage.layer setBorderWidth:2.0];
    [personalImage.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [personalImage setBackgroundImage:[UIImage imageNamed:@"personal"] forState:UIControlStateNormal];
    [headerView addSubview:personalImage];
    
    return headerView;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
